A5.u.array.dsvfrom Method
Syntax
Arguments
- stringstring
The string with delimiter-separated values.
- settingsobjectstring
The settings to use when parsing the passed in string. If only the "value" separator needs to be specified a string with that character maybe used.
- separatorobjectstring
The specification for what characters are used to separate values and rows. If only the "value" separator needs to be specified a string with that character maybe used.
- valuestring
The character to use when splitting values. The default is ",".
- rowstring
The character to use when splitting rows. The default is a new line.
- escapestringboolean
The character to use for escaping a "value" or "row" separator by placing the escape character before separator character. If no character is specified then the only way a "value" or "row" separator will be escaped is by it being inside a quoted string.
- quoteobjectstring
The specification for what character is used to create a quoted value. If only the "value" of the quote character needs to be specified a string with that character maybe used. The "escape" character will be the same as the "value" character.
- valuestring
The character to use when creating a quoted value. The default is a quote (").
- escapestringboolean
The character to use for escaping the quote character by placing the escape character before the quote character. The default is a quote (").
- convertobject
Rules for converting values in the passed in data to specific variable types.
- numberobjectboolean
If true or an object, then values that are numeric will be converted to a number in the output data.
- decimalstring
The character to use as a decimal. The default is ".".
- nullsstringarray
One or more values to from the passed in data to be converted into a null value when the data is processed.
- booleansobjectboolean
If an object is passed in, then values in the passed in data will be converted to booleans.
- truthystringarray
One or more values to from the passed in data to be converted into a true value when the data is processed.
- falseystringarray
One or more values to from the passed in data to be converted into a false value when the data is processed.
- arrayarray
The resulting data array.
Description
Convert a string with delimiter-separated values into and array.
Discussion
The A5.u.array.dsv.from method can convert one of the many delimiter-separated values formats and convert it into am object. The names of columns in the data will always be assumed to be the first row of text.
This function takes a string of delimited values and creates an array of objects. The basic syntax is:
obj = A5.u.array.dsv.from(string[,settings])
The returned obj is the resulting array of objects created by the function. The string argument is the delimited string to convert. The optional settings object can be used to specify the separator character (defaults to ",") and the quote character (defaults to "). Additional settings allow you to control how rows are separated, how values are escaped, and how numeric, null, or boolean values are converted.